package com.sen.common.widget.media;

import java.util.LinkedList;
import java.util.List;

import com.sen.common.widget.ToHtmlable;

/**
 * @author sen
 */
public class JavaScript implements ToHtmlable {

	private List<String> contents = new LinkedList<String>();
	
	public JavaScript() {
		// empty
	}
	
	public JavaScript(String content) {
		contents.add(content);
	}
	
	public JavaScript add(String content) {
		contents.add(content);
		return this;
	}
	
	public String toHtml() {
		StringBuffer buffer = new StringBuffer();
		buffer.append("<script type='text/javascript'>");
		for (String content : contents) {
			buffer.append(content);
		}
		buffer.append("</script>");
		return buffer.toString();
	}
	
}
